package com.bosssoft.cloud.wechat.common.controller;

import com.bosssoft.cloud.wechat.common.bean.PageInfo;
import com.bosssoft.cloud.wechat.common.bean.ckrecord.CkRcdCondParam;
import com.bosssoft.cloud.wechat.common.service.AppCheckRecordService;
import com.bosssoft.cloud.wechat.infrastructure.annotation.RequestParams;
import com.bosssoft.cloud.wechat.infrastructure.bean.response.R;
import com.bosssoft.cloud.wechat.infrastructure.enums.ResultEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * 查验票据信息记录
 *
 * @author wcy create on 2021/5/20 13:51 下午
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping(value = "checkRecord")
@Api("查验记录Api")
public class AppCheckRecordController {

    @Autowired
    private AppCheckRecordService acrService;

    /**
     * 根据票据名称or单位名称查询记录
     *
     * @param param    条件param
     * @param pageInfo 分页信息
     * @return 记录
     */
    @ApiOperation("获取查验票据记录")
    @GetMapping(value = "query", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<?> param(@ApiParam("条件查询") @RequestParams CkRcdCondParam param, PageInfo pageInfo) {
        return new R<>(ResultEnum.SUCCESS, acrService.pageByOpenidAndKeyword(param, pageInfo));
    }

    /*
     TODO 待定
     目前用不上但应该用上，正常逻辑是调此接口获取票据查验记录，但目前直接调用查票接口
     */
    @ApiOperation("通过id获取查验票据信息记录")
    @GetMapping("/getById")
    public R<?> getByOpenid(@RequestParam String id) {
        return new R<>(ResultEnum.SUCCESS, acrService.getById(id));
    }
}
